package app.fugema.shop.main.goods.view;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.base.common.netBeanPackage.LiveDataWrapper;
import com.base.common.utils.OnClickCheckedUtil;
import com.base.common.utils.UIUtils;
import com.base.common.view.adapter.MyLinearLayoutManager;
import com.base.common.view.adapter.ada.GeneralRecyclerAdapter;
import com.base.common.view.base.BaseActivity;
import com.base.common.view.base.OnGetDataListener;
import com.base.common.viewmodel.BaseViewObserver;
import app.fugema.shop.R;
import app.fugema.shop.databinding.SeckillPrecinctActivityBinding;
import app.fugema.shop.main.goods.adapter.SeckillPrecinctItemMultiType;
import app.fugema.shop.main.goods.adapter.SeckillPrecinctTopBannerItemMultiType;
import app.fugema.shop.main.goods.adapter.SeckillPrecinctTopSpecialOfferItemMultiType;
import app.fugema.shop.main.goods.adapter.SeckillPrecinctTopTodayItemMultiType;
import app.fugema.shop.main.goods.adapter.SeckillPrecinctTopYouLikeItemMultiType;
import app.fugema.shop.main.goods.vm.GoodsVM;
import app.fugema.shop.main.order.model.GroupBookingBean;

public class SeckillPrecinctActivity extends BaseActivity<SeckillPrecinctActivityBinding, GoodsVM> implements OnGetDataListener {

    public static void start(Context context) {
        context.startActivity(new Intent(context, SeckillPrecinctActivity.class));
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.seckill_precinct_activity);

    }

    private GeneralRecyclerAdapter adapter;

    @Override
    protected void initView() {
        super.initView();
        binding.tvTitleCenter.setText("秒杀专区");
        binding.ivImageLeftClose.setOnClickListener(new OnClickCheckedUtil() {
            @Override
            public void onClicked(View view) {
                finish();
            }
        });
        viewUtils.setRefreshStateLayout(binding.rvRecyclerView, this, this);
        binding.rvRecyclerView.setLayoutManager(new MyLinearLayoutManager(this));
        adapter = new GeneralRecyclerAdapter() {
            @Override
            public void initMultiItemType() {
                putMultiItemType(new SeckillPrecinctTopSpecialOfferItemMultiType());
                putMultiItemType(new SeckillPrecinctTopBannerItemMultiType());
                putMultiItemType(new SeckillPrecinctTopYouLikeItemMultiType());
                putMultiItemType(new SeckillPrecinctTopTodayItemMultiType());

                putMultiItemType(new SeckillPrecinctItemMultiType());
            }
        };
        binding.rvRecyclerView.setAdapter(adapter);


//        List<Object> list = new ArrayList<>();
//
//        list.add(new HeaderBean(BaseItemTypeInterface.TYPE_HEAD));
//        list.add(new HeaderBean(BaseItemTypeInterface.TYPE_HEAD_ONE));
//        list.add(new HeaderBean(BaseItemTypeInterface.TYPE_HEAD_TWO));
//        list.add(new HeaderBean(BaseItemTypeInterface.TYPE_HEAD_THREE));
//
//        adapter.setDataList(list);

    }

    @Override
    protected void initData(Intent intent) {
        super.initData(intent);
        onGetData(1);
    }

    @Override
    public void onGetData(int pn)
    {
        //秒杀商品
        /*
        viewModel.pageSecKillProd(pn).observe(this, new BaseViewObserver<LiveDataWrapper<GroupBookingBean>>(viewUtils.getStateLayout()) {
            @Override
            protected void onSuccess(LiveDataWrapper<GroupBookingBean> data) {
                viewUtils.setDataListRefreshLayout(adapter, data.data.getData().getCurrent(), data.data.getData().getSize(), data.data.getData().getRecords());
            }

            @Override
            public boolean isRefreshLayoutData() {
                return true;
            }

            @Override
            public boolean isEmptyData(LiveDataWrapper<GroupBookingBean> data) {
                return UIUtils.isEmpty(data.data.getData()) || (data.data.getData().getCurrent() == 1 && UIUtils.isEmpty(data.data.getData().getRecords()));
            }
        });
        */
    }
}
